package com.yfapp.platform.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yfapp.platform.dao.template.DbUtilsTemplate;
import com.yfapp.platform.entitytest.TCust;
import com.yfapp.platform.entitytest.TCustId;
import com.yfapp.platform.service.CustService;
import com.yfapp.platform.tools.Page;
import com.yfapp.platform.tools.Pagination;

@Controller
@RequestMapping("/cust")
public class CustController {
	@Autowired
	protected DbUtilsTemplate dbUtilsTemplate;
	@Autowired
	private CustService custService;
	
	@RequestMapping(value = "/custInfolist",method = RequestMethod.POST)
	@ResponseBody
	public <T> Object custInfolist(Page page,HttpServletRequest request, HttpServletResponse response,String id) throws Throwable {
		//List<TCustId> custList = custService.getCustList();
		//Pagination<TCustId> listBean = dbUtilsTemplate.listBean(custList, page);
		Pagination<Object> listBean = custService.getCustQuery(page);
		return listBean;
	}
	@RequestMapping(value = "/custInfo")
	public String custInfo(HttpServletRequest request, HttpServletResponse response,String fcustId) throws Throwable {
		System.out.println(fcustId);
		TCustId cust = custService.getCustByIDcard(fcustId);
		System.out.println(cust.getFcustName());
		request.getSession().setAttribute("cust", cust);
		return "/jsp/cust/custInfo";
	}
	
	public HttpSession getSess(HttpServletRequest request){
		return request.getSession();
	}
}
